package logic

import (
	"2207a/bawei/user_srv/models/mysql"
	"context"

	"2207a/bawei/user_srv/internal/svc"
	"2207a/bawei/user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type LoginInfoMobileLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLoginInfoMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginInfoMobileLogic {
	return &LoginInfoMobileLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LoginInfoMobileLogic) LoginInfoMobile(in *user.LoginInfoMobileRequest) (*user.LoginInfoMobileResponse, error) {
	// todo: add your logic here and delete this line
	m := mysql.User{}
	err := m.CreateMobile(in.Mobile)
	if err != nil {
		logx.Error("手机号登录错误", err)
		return nil, err
	}
	return &user.LoginInfoMobileResponse{
		UserId: int64(m.ID),
	}, nil
}
